home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
kob
/
kob001s.lzh
/
xb2.has
< prev
next >
Wrap
Text File
|
1997-03-08
|
46KB
|
3,309 lines
*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
*
* xb2.has …… ぺけ-BASICのインタプリタ本体
*
*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
.xref ko_debug
.xref ko_dec_print
.xref ko_hex_print
.include kob.h
.include doscall.mac
.include iocscall.mac
.include fefunc.h
.include variable.h
* .xref error
* .xref errors
.xref error_sub
.xref errors_sub
.xref dec_print
* .xref init_tpal
.xref endendend
.xref I行数算出
.xref a6保存
IERROR .macro num
bsr I行数算出
moveq #num,d0
bsr error_sub
bra _kob_exec_err
.endm
IERRORS .macro num
bsr I行数算出
moveq #num,d0
bsr errors_sub
bra _kob_exec_err
.endm
.offset 0
Aint: .ds.l 1
Astr: .ds.l 1
Afloat: .ds.l 1
Achar: .ds.l 1
Asysvar: .ds.l 1
orgstrbuf: .ds.l 1
orgSP: .ds.l 1
*DIEI: .ds.b 1
* .ds.b 3
Adim:
.text
.even
.xdef _kobas_init_exec
_kobas_init_exec:
movem.l d3-d7/a3-a6,-(sp)
move.l a6保存(pc),a6
* clr.w xb動作mode
* move.l xbFLAG,d7
* move.l 変数area,-(sp) * 最初だけは global 変数に領域を預けるのだよ(そんなことわかりきってるだろうに馬鹿だねえ)
move.l b_argv,-(sp)
subq.l #4,sp
move.w #$0003,-(sp) * str (関係ないけど一応)
move.l b_argc,-(sp)
subq.l #4,sp
move.w #$0001,-(sp) * int (関係ないけど一応)
move.w #2,-(sp) * 2個
move.l 中間言語,-(sp)
clr.l -(sp) * auto システム変数
bsr _kob_exec
lea.l 4+4+2+10+10(sp),sp
.xref _kob_flag
clr.w _kob_flag
movem.l (sp)+,d3-d7/a3-a6
moveq #0,d0
rts
.xdef _kob_exec
_kob_exec:
* KH '変数area = ',変数area
lea.l 12(sp),a3 * 引き数列先頭(引き数の個数込み)
movem.l 4(sp),a4/a5 * auto sysvar/program point
movea.l 4+変数INIT,a0
adda.w (a5)+,a0 * 変数確保リストの先頭アドレス
move.w 4+8(a0),d0 * 配列の個数 - 1
lsl.w #2,d0
add.w #Adim+4,d0 * Adim + 配列の個数 * 4
movea.l a4,a1 * auto システム変数
movea.l 変数area,a4 * 変数ハンドラ
move.l sp,orgSP(a4)
move.l a1,Asysvar(a4)
lea.l (a4,d0.w),a1 * (auto)変数のハンドルを収める領域を確保
move.l a3,-(sp) * 引き数列先頭 保存&パラメーター渡し
tst.b d7
bmi auto_vc
lea.l Adim(a4),a2
move.l a2,配列
move.l a2,-(sp)
pea.l 変数float
pea.l 変数char
pea.l 変数str
pea.l 変数int
bra @f
auto_vc:
pea.l Adim(a4)
pea.l Afloat(a4)
pea.l Achar(a4)
pea.l Astr(a4)
pea.l Aint(a4)
@@:
bsr Variable_clr_sub * 変数領域確保 & 引き数セット
lea.l 4*6(sp),sp
* clr.b DIEI(a4) * EI
move.l strbuf,orgstrbuf(a4)
main_loop:
main_cont:
move.l orgstrbuf(a4),strbuf
moveq #0,d4 * いらない
move.w (a5)+,d4
* KH 'statement 番号',d4
* tst.w d4
bmi 式
beq 関数呼び出し
statement:
move.w stt(pc,d4.w),d4
jmp stt(pc,d4.w)
stt:
.dc.w 関数呼び出し-stt *
.dc.w Color-stt
.dc.w Console-stt
.dc.w Locate-stt
.dc.w Lprint-stt
.dc.w Print-stt
.dc.w Width-stt
.dc.w Screen-stt
.dc.w Break-stt
.dc.w Case-stt *
.dc.w Continue-stt *10
.dc.w Default-stt *
.dc.w Endfunc-stt
.dc.w Switch2-stt
.dc.w Error-stt
.dc.w Return-stt
.dc.w Switch-stt
.dc.w Beep-stt
.dc.w Cls-stt
.dc.w End-stt
.dc.w Endwhile-stt *20
.dc.w Exit-stt
.dc.w For-stt
.dc.w Gosub-stt *
.dc.w Goto-stt
.dc.w If-stt
.dc.w Input-stt
.dc.w Key-stt
.dc.w Linput-stt
.dc.w Next-stt
.dc.w Next2-stt *30
.dc.w Stop-stt
.dc.w Until-stt
.dc.w While-stt
.dc.w Dim-stt
.dc.w ColorP-stt * 35
.dc.w FuncKey-stt * 36
.dc.w CursorSW-stt * 37
.dc.w Str-stt * 38
.dc.w Func-stt
.dc.w Else-stt *40
.dc.w SysVar-stt *41
.dc.w Ifeq-stt *42
.dc.w Ifne-stt
.dc.w Iflt-stt
.dc.w Ifgt-stt
.dc.w Ifle-stt
.dc.w Ifge-stt *47
.dc.w ItSet-stt *48
関数呼び出し:
bsr function_call
*main_cont:
* move.b DIEI(a4),d0
* bne main_loop
bra main_loop
_kob_driven_end:
move.l d7,xbFLAG
move.l orgSP(a4),sp
* movem.l (sp)+,d3-d7/a3-a6
moveq #0,d0
rts
_kob_driven_err::
_kob_exec_err::
move.l d7,xbFLAG
move.l orgSP(a4),sp
* movem.l (sp)+,d3-d7/a3-a6
.xref _kobas_exit
bsr _kobas_exit
moveq #-1,d0 * 多分ここには戻ってこないけど一応形だけ
rts
** ** ** ** ** ** ** ** **
* 代入式だった
式:
btst #14,d4
beq 普通変数への代入
配列への代入:
* d4.b = 代入先の型
bsr 値get * 値を得る
move.l d0,d2
move.l d1,d3
movea.l a0,a1
bsr dim_set_sub * d2-d5/a1 保存
tst.b d4
beq int_setD
bmi float_setD
subq.b #1,d4
beq str_setD
*char_setD:
move.b d2,(a0,d0.l)
bra main_cont
str_setD:
lsl.l #8,d0
lea.l (a0,d0.l),a0
@@:
move.b (a1)+,(a0)+
bne @b
bra main_cont
float_setD:
.ifdef _XB030
movem.l d2-d3,(a0,d0.l*8)
.else
lsl.l #3,d0
movem.l d2-d3,(a0,d0.l)
.endif
bra main_cont
int_setD:
.ifdef _XB030
move.l d2,(a0,d0.l*4)
.else
lsl.l #2,d0
move.l d2,(a0,d0.l)
.endif
bra main_cont
普通変数への代入:
* d4.b = 代入先の型
bsr 値get * 値を得る
move.w (a5)+,d2 * 代入先の変数番号
bmi auto変数set
tst.b d4
beq int_set
bmi float_set
subq.b #1,d4
beq str_set
*char_set:
movea.l 変数char,a1 * とりあえず兼用
move.b d0,(a1,d2.w)
bra main_cont
float_set:
movea.l 変数float,a1 * とりあえず兼用
.ifdef _XB030
movem.l d0-d1,(a1,d2.w*8)
.else
lsl.w #3,d2
movem.l d0-d1,(a1,d2.w)
.endif
bra main_cont
str_set:
movea.l 変数str,a1 * とりあえず兼用
lsl.w #8,d2
lea.l (a1,d2.w),a1
@@:
move.b (a0)+,(a1)+
bne @b
bra main_cont
int_set:
movea.l 変数int,a1 * とりあえず兼用
.ifdef _XB030
move.l d0,(a1,d2.w*4)
.else
lsl.w #2,d2
move.l d0,(a1,d2.w)
.endif
bra main_cont
auto変数set:
not.w d2
tst.b d4
beq int_setA
bmi float_setA
subq.b #1,d4
beq str_setA
*char_set:
movea.l Achar(a4),a1
move.b d0,(a1,d2.w)
bra main_cont
float_setA:
movea.l Afloat(a4),a1
.ifdef _XB030
movem.l d0-d1,(a1,d2.w*8)
.else
lsl.w #3,d2
movem.l d0-d1,(a1,d2.w)
.endif
bra main_cont
str_setA:
movea.l Astr(a4),a1
lsl.w #8,d2
lea.l (a1,d2.w),a1
@@:
move.b (a0)+,(a1)+
bne @b
bra main_cont
int_setA:
movea.l Aint(a4),a1
.ifdef _XB030
move.l d0,(a1,d2.w*4)
.else
lsl.w #2,d2
move.l d0,(a1,d2.w)
.endif
bra main_cont
stack_over:
IERROR 8
** ** ** main_cont 部分終わり ** ** ** **
** ** ** ** ** ** ** ** **
float値get:
moveq #-1,d4
bra 値get
str値get:
moveq #1,d4
* (d4.b) 型の数式を評価して、( (d1/)d2-d4/a1 保存 )
* int の時、 d0 に値を返す
* float d0-d1
* str a0
値get: * どこかで d4.l を破壊している
move.w (a5)+,d0
tst.b d0
beq ig111
bmi fg111
cmpi.b #2,d0
beq cg111
*sg111:
cmpi.b #1,d4
bne 型違い
move.w d4,-(sp)
move.l d1,-(sp)
bsr str_get0
move.l (sp)+,d1
move.w (sp)+,d4
rts
cg111:
tst.w d0
bmi 1f
btst #14,d0
bne char_val
bsr int_cal * int でいい
bra @f **
1:
bclr #14,d0
beq char_imm
*char_fnc:
movem.l d1-d4/a1,-(sp)
bsr function_call
movem.l (sp)+,d1-d4/a1
tst.w (a0)
bne 返り値がない
move.l 2+4(a0),d0
bra 4f
char_val:
btst #13,d0
bne char_dim
btst #12,d0
bne str_point
btst #8,d0
beq 1f
movea.l Achar(a4),a0
bra 2f
1:
movea.l 変数char,a0 * とりあえず兼用
2:
move.w (a5)+,d0
move.b (a0,d0.w),d0
bra 4f
char_dim:
move.l d1,-(sp)
bsr dim_sub
move.l (sp)+,d1
move.b (a0,d0.l),d0
bra 4f
str_point:
btst #8,d0
bne 1f
bsr int値get
movea.l 変数str,a0 * とりあえず兼用
bra 2f
1:
bsr int値get
movea.l Astr(a4),a0
2:
cmpi.w #$100,d0
bcc str_access_err
move.l d1,-(sp)
move.w (a5)+,d1
lsl.w #8,d1
add.w d0,d1
move.b (a0,d1.w),d0
move.l (sp)+,d1
bra 4f
char_imm:
move.l (a5)+,d0
* bra 4f
4:
andi.l #$000000ff,d0 * char
bra @f
ig111:
tst.w d0
bmi 1f
bclr #14,d0
bne int_val
bsr int_cal
bra @f
int_val:
btst #13,d0
bne int_dim
btst #8,d0
bne auto_int_val
move.w (a5)+,d0
bge normal_int_var
bsr int_system_var
bra @f
1:
bclr #14,d0
beq int_imm
int_fnc:
movem.l d1-d4/a1,-(sp)
bsr function_call
movem.l (sp)+,d1-d4/a1
tst.w (a0)
bne 返り値がない
move.l 2+4(a0),d0
bra @f
normal_int_var:
movea.l 変数int,a0 * とりあえず兼用
.ifdef _XB030
move.l (a0,d0.w*4),d0
.else
lsl.w #2,d0
move.l (a0,d0.w),d0
.endif
bra @f
auto_int_val:
move.w (a5)+,d0
movea.l Aint(a4),a0
.ifdef _XB030
move.l (a0,d0.w*4),d0
.else
lsl.w #2,d0
move.l (a0,d0.w),d0
.endif
bra @f
int_dim:
move.l d1,-(sp)
bsr dim_sub
move.l (sp)+,d1
.ifdef _XB030
move.l (a0,d0.l*4),d0
.else
lsl.l #2,d0
move.l (a0,d0.l),d0
.endif
bra @f
int_imm:
move.l (a5)+,d0
* bra @f
@@:
tst.b d4
beq ig111_ok
bmi float_trans
cmpi.b #1,d4
beq 型違い * str
* andi.l #$000000ff,d0 * char
ig111_ok:
rts * int,char 同士
float_trans:
FPACK __LTOD * float <- int,char
rts
fg111:
move.l d1,-(sp) *
move.w d4,-(sp)
bsr float_get0
move.w (sp)+,d4
tst.b d4
beq int_trans
bmi fl_ok
cmpi.b #1,d4
beq 型違い
FPACK __DTOL * char <- float
andi.l #$ff,d0
move.l (sp)+,d1
rts
int_trans:
FPACK __DTOL * int <- float
move.l (sp)+,d1
rts
fl_ok:
addq.l #4,sp * float 同士
rts
int値get: * d4.l 保存!!
move.w (a5)+,d0
tst.b d0
beq ig112
bmi fg112
cmpi.b #2,d0
bne 型違い
*cg112:
tst.w d0
bmi 1f
btst #14,d0
bne char_val2
bsr int_cal * int でいい
rts
* bra 4f
1:
bclr #14,d0
beq char_imm2
*char_fnc2:
movem.l d1-d4/a1,-(sp)
bsr function_call
movem.l (sp)+,d1-d4/a1
tst.w (a0)
bne 返り値がない
move.l 2+4(a0),d0
bra 4f
char_val2:
btst #13,d0
bne char_dim2
btst #12,d0
bne str_point2
btst #8,d0
beq 1f
movea.l Achar(a4),a0
bra 2f
1:
movea.l 変数char,a0 * とりあえず兼用
2:
move.w (a5)+,d0
move.b (a0,d0.w),d0
bra 4f
char_dim2:
move.l d1,-(sp)
bsr dim_sub
move.l (sp)+,d1
move.b (a0,d0.l),d0
bra 4f
str_point2:
btst #8,d0
bne 1f
bsr int値get
movea.l 変数str,a0 * とりあえず兼用
bra 2f
1:
bsr int値get
movea.l Astr(a4),a0
2:
move.l d1,-(sp)
cmpi.w #$100,d0
bcc str_access_err
move.w (a5)+,d1
lsl.w #8,d1
add.w d0,d1
move.b (a0,d1.w),d0
move.l (sp)+,d1
bra 4f
char_imm2:
move.l (a5)+,d0
* bra 4f
4:
andi.l #$000000ff,d0 * char
rts
ig112:
tst.w d0
bmi 1f
bclr #14,d0
bne int_val2
bsr int_cal
rts
int_val2:
btst #13,d0
bne int_dim2
btst #8,d0
bne auto_int_val2
move.w (a5)+,d0
bge normal_int_var2
bra int_system_var
*bsr int_system_var
*rts
1:
bclr #14,d0
beq int_imm2
int_fnc2:
movem.l d1-d4/a1,-(sp)
bsr function_call
movem.l (sp)+,d1-d4/a1
tst.w (a0)
bne 返り値がない
move.l 2+4(a0),d0
rts
normal_int_var2:
movea.l 変数int,a0 * とりあえず兼用
.ifdef _XB030
move.l (a0,d0.w*4),d0
.else
lsl.w #2,d0
move.l (a0,d0.w),d0
.endif
rts
auto_int_val2:
move.w (a5)+,d0
movea.l Aint(a4),a0
.ifdef _XB030
move.l (a0,d0.w*4),d0
.else
lsl.w #2,d0
move.l (a0,d0.w),d0
.endif
rts
int_dim2:
move.l d1,-(sp)
bsr dim_sub
move.l (sp)+,d1
.ifdef _XB030
move.l (a0,d0.l*4),d0
.else
lsl.l #2,d0
move.l (a0,d0.l),d0
.endif
rts
int_imm2:
move.l (a5)+,d0
rts
fg112:
move.l d1,-(sp) *
move.w d4,-(sp)
bsr float_get0
move.w (sp)+,d4
FPACK __DTOL * int <- float
move.l (sp)+,d1
rts
型違い:
IERROR 31
返り値がない:
IERROR 49
* * * * * * * *
float_get0:
tst.w d0
bmi fg1
btst #14,d0
beq float_cal
* float_val
btst #13,d0
bne float_dim
btst #8,d0
beq 1f
movea.l Afloat(a4),a0
bra 2f
1:
movea.l 変数float,a0 * とりあえず兼用
2:
move.w (a5)+,d0
lsl.w #3,d0
movem.l (a0,d0.w),d0-d1
rts
float_dim:
bsr dim_sub
lsl.l #3,d0
movem.l (a0,d0.l),d0-d1
rts
fg1:
bclr #14,d0
beq float_imm
* float_fnc
movem.l d2-d4/a1,-(sp)
bsr function_call
movem.l (sp)+,d2-d4/a1
tst.w (a0)
bne 返り値がない
movem.l 2(a0),d0-d1
rts
float_imm:
movem.l (a5)+,d0/d1
rts
float_cal:
movem.l d2-d3,-(sp)
move.w (a5)+,d0
* add.w d0,d0
move.w fc(pc,d0.w),d0
jmp fc(pc,d0.w)
fc:
.dc.w 0 * dummy
.dc.w Fmul-fc
.dc.w Fdiv-fc
.dc.w Fdiv2-fc
.dc.w Fmod-fc
.dc.w Fadd-fc
.dc.w Fsub-fc
.dc.w Fshr-fc
.dc.w Fshl-fc
.dc.w Fequal-fc
.dc.w Fnoteq-fc
.dc.w Fsmall-fc
.dc.w Flarge-fc
.dc.w Feq_small-fc
.dc.w Feq_large-fc
.dc.w Fnot-fc
.dc.w Fand-fc
.dc.w FFor-fc
.dc.w Fxor-fc
.dc.w Fminus-fc
Fmul:
bsr float値get
move.l d0,d2
move.l d1,d3
bsr float値get
FPACK __DMUL * 手抜き
bra float_cal_end
Fdiv:
bsr float値get
move.l d0,d2
move.l d1,d3
bsr float値get
exg.l d0,d2
exg.l d1,d3
FPACK __DDIV * 手抜き
bra float_cal_end
Fdiv2:
bsr float値get
FPACK __DTOL
move.l d0,d2
bsr float値get
FPACK __DTOL
move.l d0,d1
move.l d2,d0
FPACK __LDIV * 手抜き
FPACK __LTOD
bra float_cal_end
Fmod:
bsr float値get
FPACK __DTOL
move.l d0,d2
bsr float値get
FPACK __DTOL
move.l d0,d1
move.l d2,d0
FPACK __LMOD * 手抜き
FPACK __LTOD
bra float_cal_end
Fadd:
bsr float値get
move.l d0,d2
move.l d1,d3
bsr float値get
FPACK __DADD * 手抜き
bra float_cal_end
Fsub:
bsr float値get
move.l d0,d2
move.l d1,d3
bsr float値get
exg.l d0,d2
exg.l d1,d3
FPACK __DSUB * 手抜き
bra float_cal_end
Fminus:
bsr float値get
bchg #31,d0 * 符号反転
bra float_cal_end
Fequal:
Fnoteq:
Fsmall:
Flarge:
Feq_small:
Feq_large:
Fshr:
Fshl:
Fnot:
Fand:
FFor:
Fxor:
.xdef floatにない演算
floatにない演算:
IERROR 2
float_cal_end:
movem.l (sp)+,d2-d3
rts
** ** ** ** ** **
str_get0:
tst.w d0
bmi sg1
btst #14,d0
beq str_cal
* str_val
btst #13,d0
bne str_dim
btst #8,d0
bne auto_str_var
move.w (a5)+,d0
bge normal_str_var
* str_system_var
add.w d0,d0
move.w str_sys(pc,d0.w),d0
jmp str_sys(pc,d0.w)
.dc.w Inkey0-str_sys
.dc.w Inkey-str_sys
.dc.w Time-str_sys
.dc.w Day-str_sys
.dc.w Date-str_sys
str_sys:
Date:
IOCS _DATEGET
move.l d0,d1 * BCD
IOCS _DATEBIN
move.l d0,d1 * binary
lsl.l #4,d1
ori.b #$02,d1 * yy/mm/dd
ror.l #4,d1
movea.l strbuf,a0
addi.l #$100,strbuf
move.l a1,-(sp)
movea.l a0,a1
IOCS _DATEASC
move.l (sp)+,a1
rts
Day:
IOCS _DATEGET
swap d0
lsr.w #8,d0
moveq #0,d1
move.b d0,d1 * 曜日
movea.l strbuf,a0
addi.l #$100,strbuf
move.l a1,-(sp)
movea.l a0,a1
IOCS _DAYASC
move.l (sp)+,a1
rts
Time:
IOCS _TIMEGET
move.l d0,d1 * BCD
IOCS _TIMEBIN
move.l d0,d1 * binary
movea.l strbuf,a0
addi.l #$100,strbuf
move.l a1,-(sp)
movea.l a0,a1
IOCS _TIMEASC
move.l (sp)+,a1
rts
Inkey0:
Inkey:
IERROR 72 * こBでは使えない命令
normal_str_var:
movea.l 変数str,a0 * とりあえず兼用
lsl.w #8,d0
lea.l (a0,d0.w),a0
rts
auto_str_var:
move.w (a5)+,d0
movea.l Astr(a4),a0
lsl.w #8,d0
lea.l (a0,d0.w),a0
rts
str_dim:
bsr dim_sub
lsl.l #8,d0
lea.l (a0,d0.l),a0
rts
sg1:
bclr #14,d0
beq str_imm
* str_fnc
movem.l d2-d4/a1,-(sp)
bsr function_call
tst.w (a0)
bne 返り値がない
movea.l 2+4(a0),a1
movea.l strbuf,a0
addi.l #$100,strbuf
move.l a0,d2 * 保存
@@:
move.b (a1)+,(a0)+
bne @b
movea.l d2,a0
movem.l (sp)+,d2-d4/a1
rts
str_imm:
movea.l a5,a0
@@:
tst.b (a5)+
bne @b
addq.l #1,a5
move.l a5,d0
bclr #0,d0
movea.l d0,a5
rts
str_cal:
move.w (a5)+,d0
cmpi.w #5*2,d0 * '+'
bne strに足し算以外
movea.l strbuf,a0
addi.l #$100,strbuf
movem.l a0/a1,-(sp)
move.w #255-1,d1
movea.l a0,a1
bsr str値get
@@:
move.b (a0)+,(a1)+
dbeq d1,@b
subq.l #1,a1
bsr str値get
@@:
move.b (a0)+,(a1)+
dbeq d1,@b
clr.b (a1)
movem.l (sp)+,a0/a1
rts
** ** ** ** ** **
** ** ** ** ** **
int_system_var:
cmpi.w #-10,d0
ble info_sys
add.w d0,d0
move.w int_sys(pc,d0.w),d0
jmp int_sys(pc,d0.w)
.dc.w Itime-int_sys
.dc.w Winv-int_sys
.dc.w Winh-int_sys
.dc.w Winy-int_sys
.dc.w Winx-int_sys
.dc.w Pos-int_sys
.dc.w Free-int_sys
.dc.w Errno-int_sys
.dc.w Csrlin-int_sys
int_sys:
info_sys:
neg.w d0
lsl.w #2,d0
* .xref global_info
* lea.l global_info(pc),a0
tst.l Asysvar(a4) * 遅いけど~
beq info_sys_err
move.l Asysvar(a4),a0 * auto システム変数
move.l -40+4(a0,d0.w),d0 *?
rts
info_sys_err:
IERROR 86
Csrlin:
Pos:
moveq #0,d0
rts
Free:
move.l mem_last,d0
sub.l 変数area,d0
rts
Errno:
move.l errorno,d0
rts
Winx:
.xref _WINX
move.l _WINX(pc),d0
rts
Winy:
.xref _WINY
move.l _WINY(pc),d0
rts
Winh:
.xref _WINH
move.l _WINH(pc),d0
rts
Winv:
.xref _WINV
move.l _WINV(pc),d0
rts
Itime:
.xref _ITIME
move.l _ITIME(pc),d0
rts
int_cal:
move.w (a5)+,d0
move.w ic(pc,d0.w),d0
jmp ic(pc,d0.w)
ic:
.dc.w 0 * dummy
.dc.w Imul-ic
.dc.w Idiv-ic
.dc.w Idiv2-ic
.dc.w Imod-ic
.dc.w Iadd-ic
.dc.w Isub-ic
.dc.w Ishr-ic
.dc.w Ishl-ic
.dc.w Iequal-ic
.dc.w Inoteq-ic
.dc.w Ismall-ic
.dc.w Ilarge-ic
.dc.w Ieq_small-ic
.dc.w Ieq_large-ic
.dc.w Inot-ic
.dc.w Iand-ic
.dc.w Ior-ic
.dc.w Ixor-ic
.dc.w Iminus-ic * $13
.dc.w 0 * reserve $14
.dc.w 0 * reserve $15
.dc.w 0 * reserve $16
.dc.w 0 * reserve $17
.dc.w 0 * reserve $18
.dc.w 0 * reserve $19
.dc.w 0 * reserve $1a
.dc.w 0 * reserve $1b
.dc.w 0 * reserve $1c
.dc.w 0 * reserve $1d
.dc.w 0 * reserve $1e
.dc.w 0 * reserve $1f
.dc.w Iadd1-ic * $20
.dc.w Iadd2-ic
.dc.w Iadd3-ic
.dc.w Iadd4-ic
.dc.w Iadd5-ic
.dc.w Iadd6-ic
.dc.w Iadd7-ic
.dc.w Iadd8-ic
.dc.w Isub1-ic * $28
.dc.w Isub2-ic
.dc.w Isub3-ic
.dc.w Isub4-ic
.dc.w Isub5-ic
.dc.w Isub6-ic
.dc.w Isub7-ic
.dc.w Isub8-ic
.dc.w Imul02-ic * $30
.dc.w Imul03-ic
.dc.w Imul04-ic
.dc.w Imul05-ic
.dc.w Imul06-ic
.dc.w Imul07-ic
.dc.w Imul08-ic
.dc.w Imul09-ic
.dc.w Imul10-ic
.dc.w Imul11-ic
.dc.w Imul12-ic
.dc.w Imul13-ic
.dc.w Imul14-ic
.dc.w Imul15-ic
.dc.w Imul16-ic
.dc.w 0 * reserve $3f
.dc.w Imul32-ic
.dc.w Imul64-ic
.dc.w Imul128-ic
.dc.w Imul256-ic
.dc.w 0 * reserve $44
.dc.w 0 * reserve $45
.dc.w 0 * reserve $46
.dc.w 0 * reserve $47
.dc.w Idiv2_1-ic * $48
.dc.w Idiv2_2-ic
.dc.w Idiv2_3-ic
.dc.w Idiv2_4-ic
.dc.w Idiv2_5-ic
.dc.w Idiv2_6-ic
.dc.w Idiv2_7-ic
.dc.w Idiv2_8-ic
.dc.w Ishr1-ic * $50
.dc.w Ishr2-ic
.dc.w Ishr3-ic
.dc.w Ishr4-ic
.dc.w Ishr5-ic
.dc.w Ishr6-ic
.dc.w Ishr7-ic
.dc.w Ishr8-ic
Imul:
.ifdef _XB030
bsr int値get
move.l d0,-(sp)
bsr int値get
muls.l (sp)+,d0
.else
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
FPACK __LMUL
move.l (sp)+,d1
.endif
rts
Idiv:
Idiv2:
.ifdef _XB030
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
tst.l d0
beq zero_div
exg d0,d1
divs.l d1,d0
move.l (sp)+,d1
.else
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
tst.l d0
beq zero_div
exg d0,d1
FPACK __LDIV * 手抜き
move.l (sp)+,d1
.endif
rts
Imod:
.ifdef _XB030
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
tst.l d0
beq zero_div
divsl.l d0,d0:d1
move.l (sp)+,d1
.else
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
tst.l d0
beq zero_div
exg d0,d1
FPACK __LMOD * 手抜き
move.l (sp)+,d1
.endif
rts
Iadd:
bsr int値get
move.l d0,-(sp)
bsr int値get
add.l (sp)+,d0
rts
Isub:
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
sub.l d0,d1
move.l d1,d0
move.l (sp)+,d1
rts
Ishr:
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
lsr.l d0,d1
move.l d1,d0
move.l (sp)+,d1
rts
Ishl:
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
lsl.l d0,d1
move.l d1,d0
move.l (sp)+,d1
rts
* 実数・文字列の比較の時有り
二数比較:
* tst.b d0
bmi 二比float
subq.b #2,d0
beq 二比char
*二比str:
movem.l d4/a1,-(sp)
bsr str値get
move.l a0,a1
bsr str値get
@@:
move.b (a0)+,d0
beq @f
cmp.b (a1)+,d0
beq @b
movem.l (sp)+,d4/a1
rts
@@:
cmp.b (a1),d0
movem.l (sp)+,d4/a1
rts
二比float:
move.w d4,-(sp)
bsr float値get
move.l d0,d2
move.l d1,d3
bsr float値get
move.w (sp)+,d4
FPACK __DCMP
rts
二比char:
bsr int値get
move.l d0,d1
bsr int値get
cmp.b d1,d0
rts
Iequal:
move.l d1,-(sp)
move.b 1(a5),d0
beq 二比int_eq
bsr 二数比較
beq true
bra false
二比int_eq:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
beq true
bra false
Inoteq:
move.l d1,-(sp)
move.b 1(a5),d0
beq 二比int_ne
bsr 二数比較
bne true
bra false
二比int_ne:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
bne true
bra false
Ismall:
move.l d1,-(sp)
move.b 1(a5),d0
beq @f
bsr 二数比較
bhi true
bra false
@@:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
bgt true
bra false
Ilarge:
move.l d1,-(sp)
move.b 1(a5),d0
beq @f
bsr 二数比較
bcs true
bra false
@@:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
blt true
bra false
Ieq_small:
move.l d1,-(sp)
move.b 1(a5),d0
beq @f
bsr 二数比較
bcc true
bra false
@@:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
bge true
bra false
Ieq_large:
move.l d1,-(sp)
move.b 1(a5),d0
beq @f
bsr 二数比較
bls true
bra false
@@:
bsr int値get
move.l d0,d1
bsr int値get
cmp.l d1,d0
ble true
bra false
true:
moveq #-1,d0
move.l (sp)+,d1
rts
false:
moveq #0,d0
move.l (sp)+,d1
rts
Inot:
bsr int値get
not.l d0
rts
Iand:
bsr int値get
move.l d0,-(sp)
bsr int値get
and.l (sp)+,d0
rts
Ior:
bsr int値get
move.l d0,-(sp)
bsr int値get
or.l (sp)+,d0
rts
Ixor:
move.l d1,-(sp)
bsr int値get
move.l d0,d1
bsr int値get
eor.l d1,d0
move.l (sp)+,d1
rts
Iminus:
bsr int値get
neg.l d0
rts
.irpc ch,12345678
Iadd&ch:
bsr int値get
addq.l #&ch,d0
rts
.endm
.irpc ch,12345678
Isub&ch:
bsr int値get
subq.l #&ch,d0
rts
.endm
Idiv2_1:
bsr int値get
tst.l d0
bge @f
addq.l #1,d0
@@:
asr.l #1,d0
rts
Idiv2_2:
bsr int値get
tst.l d0
bge @f
addq.l #3,d0
@@:
asr.l #2,d0
rts
Idiv2_3:
bsr int値get
tst.l d0
bge @f
addq.l #7,d0
@@:
asr.l #3,d0
rts
.irpc ch,45678
Idiv2_&ch:
bsr int値get
tst.l d0
bge @f
neg.l d0
asr.l #&ch,d0
neg.l d0
rts
@@:
asr.l #&ch,d0
rts
.endm
.irpc ch,12345678
Ishr&ch:
bsr int値get
lsr.l #&ch,d0
rts
.endm
Imul02:
bsr int値get
add.l d0,d0
rts
Imul03:
bsr int値get
move.l d0,-(sp)
add.l d0,d0
add.l (sp)+,d0
rts
Imul04:
bsr int値get
lsl.l #2,d0
rts
Imul05:
bsr int値get
move.l d0,-(sp)
lsl.l #2,d0
add.l (sp)+,d0
rts
Imul06:
bsr int値get
add.l d0,d0
move.l d0,-(sp)
add.l d0,d0
add.l (sp)+,d0
rts
Imul07:
bsr int値get
move.l d0,-(sp)
lsl.l #3,d0
sub.l (sp)+,d0
rts
Imul08:
bsr int値get
lsl.l #3,d0
rts
Imul09:
bsr int値get
move.l d0,-(sp)
lsl.l #3,d0
add.l (sp)+,d0
rts
Imul10:
bsr int値get
add.l d0,d0
move.l d0,-(sp)
lsl.l #2,d0
add.l (sp)+,d0
rts
Imul11:
bsr int値get
move.l d0,-(sp)
add.l d0,d0
add.l d0,(sp)
lsl.l #2,d0
add.l (sp)+,d0
rts
Imul12:
bsr int値get
lsl.l #2,d0
move.l d0,-(sp)
add.l d0,d0
add.l (sp)+,d0
rts
Imul13:
bsr int値get
move.l d0,-(sp)
lsl.l #2,d0
add.l d0,(sp)
add.l d0,d0
add.l (sp)+,d0
rts
Imul14:
bsr int値get
add.l d0,d0
move.l d0,-(sp)
lsl.l #3,d0
sub.l (sp)+,d0
rts
Imul15:
bsr int値get
move.l d0,-(sp)
lsl.l #4,d0
sub.l (sp)+,d0
rts
Imul16:
bsr int値get
lsl.l #4,d0
rts
Imul32:
bsr int値get
lsl.l #5,d0
rts
Imul64:
bsr int値get
lsl.l #6,d0
rts
Imul128:
bsr int値get
lsl.l #7,d0
rts
Imul256:
bsr int値get
lsl.l #8,d0
rts
.xdef strに足し算以外
strに足し算以外:
IERROR 2
zero_div:
IERROR 69
.xdef dim_sub
dim_sub:
move.w (a5)+,d1 * 配列番号
btst #8,d0
beq @f
lea.l Adim(a4),a0
bra dim3
.xdef dim_set_sub
dim_set_sub:
move.w (a5)+,d1 * 配列番号
bge @f
not.w d1
lea.l Adim(a4),a0 * auto
bra dim3
@@:
movea.l 配列,a0 * global
dim3:
.ifdef _XB030
movea.l (a0,d1.w*4),a0 * 配列ポインタ
.else
lsl.w #2,d1
movea.l (a0,d1.w),a0 * 配列ポインタ
.endif
move.w 4(a0),d1 * 次元 - 1
addq.l #8,a0
beq one_dim
* 二次元以上の時
movem.l d2-d5/a1,-(sp)
move.w d1,d5
.ifdef _XB030
lea.l 2(a0,d1.w*2),a1
.else
add.w d1,d1
lea.l 2(a0,d1.w),a1
.endif
moveq #0,d1
bra dim4
dim5:
.ifdef _XB030
mulu.l (a1)+,d0
add.l d0,d1
.else
move.l d1,d2
move.l (a1)+,d1
FPACK __UMUL
move.l d0,d1
add.l d2,d1
.endif
dim4:
move.l a0,-(sp)
bsr int値get
movea.l (sp)+,a0
cmpi.l #$10000,d0
bcc 添え字大きすぎ
cmp.w (a0)+,d0 * 添え字の大きさ
bhi 添え字大きすぎ
dbra d5,dim5
add.l d1,d0
movea.l a1,a0
movem.l (sp)+,d2-d5/a1
rts
one_dim: * 一次元の時
move.l a0,-(sp)
bsr int値get
move.l (sp)+,a0
cmpi.l #$10000,d0
bcc 添え字大きすぎ1
cmp.w (a0)+,d0 * 添え字の大きさ
bhi 添え字大きすぎ2
rts
添え字大きすぎ1:
.if 0
move.l d0,-(sp)
bsr dec_print
move.l #$10000,(sp)
bsr dec_print
bra @f
.endif
添え字大きすぎ2:
.if 0
move.l d0,-(sp)
bsr dec_print
moveq #0,d1
move.w -2(a0),d1
move.l d1,(sp)
bsr dec_print
@@:
addq.l #4,sp
.endif
添え字大きすぎ:
tst.l d0
bmi @f
IERROR 37
@@:
IERROR 38
** ** ** ** ** ** ** **
* 各ステートメントごとの処理
Gosub: * サポートの予定は未定
IERROR 10
Case: * 呼ばれるはずのないステートメント
Default:
.xdef noSTAT
noSTAT:
IERROR 2
Func:
IERROR 76
ItSet: * ITIME に代入
* info_?? にも代入 (H8/11/11)
bsr int値get
move.w (a5)+,d1
bne @f
move.l d0,_ITIME
bra main_cont
@@:
move.l Asysvar(a4),d2
beq info_sys_err * info_?? はイベント関数内でないと使えないよ
movea.l d2,a0
lsl.w #2,d1
move.l d0,(a0,d1.w)
bra main_cont
SysVar:
bsr str値get
tst.w (a5)+
beq SetDate
SetTime:
movea.l a0,a1
IOCS _TIMECNV
move.l d0,d1
bmi ireg_set_sysvar
IOCS _TIMEBCD
move.l d0,d1
IOCS _TIMESET
bra main_cont
SetDate:
movea.l a0,a1
IOCS _DATECNV
move.l d0,d1
bmi ireg_set_sysvar
IOCS _DATEBCD
move.l d0,d1
IOCS _DATESET
bra main_cont
ireg_set_sysvar:
IERROR 70
Error:
tst.w (a5)+
beq ErrorOff
bclr #errorF,d7
bra main_cont
ErrorOff:
bset #errorF,d7
bra main_cont
Key:
bsr int値get
tst.w d0
beq key_err
cmpi.w #20,d0
bhi key_err
ori.w #$100,d0
subq.l #4,sp
move.w d0,-(sp)
bsr str値get
move.l a0,2(sp)
DOS _FNCKEY
addq.l #6,sp
bra main_cont
key_err:
IERROR 64
* 文字列ポインタへの代入
Str:
bsr int値get * 代入ポインタ
move.l d0,d1
cmpi.w #$100,d1
bcc str_access_err
bsr int値get * ほんとは char だけど
move.w (a5)+,d2 * str変数番号
bge 1f
not.w d2
movea.l Astr(a4),a0
bra 2f
1:
movea.l 変数str,a0 * とりあえず兼用
2:
lsl.w #8,d2
add.w d1,d2
tst.b (a0,d2.w)
* beq @f
move.b d0,(a0,d2.w)
bra main_cont
*@@:
* move.b d0,(a0,d2.w)
* clr.b 1(a0,d2.w) * 文字列の最後だった時のための用心
* bra main_cont
str_access_err:
IERROR 41
* 配列の初期化
Dim:
moveq #0,d1
move.w (a5)+,d1 * 型
bmi 可変長配列定義
*KH ' 配列の初期化! 型 = ',d1
movea.l 配列,a1
moveq #0,d0
move.w (a5)+,d0 * 配列番号
*KH ' 配列番号 = ',d0
*tst.w d0
bpl @f
lea.l Adim(a4),a1
not.w d0
@@:
*KH ' 配列情報ポインタリスト = ',a1
lsl.w #2,d0
movea.l (a1,d0.w),a1
*KH ' 配列情報ポインタ(注目位置) = ',a1
move.w 4(a1),d0 * 次元 *<<<<<<<<<< かときちさん報告のバスエラー箇所 (H8/12/10)
add.w d0,d0
move.w d0,d2
add.w d0,d0
add.w d2,d0 * 6倍
lea.l 10(a1,d0.w),a1 * データ領域先頭
move.w (a5)+,d2 * 個数 - 1
tst.b d1
beq int_dim_init
bmi float_dim_init
subq.b #1,d1
bne char_dim_init
str_dim_init:
movea.l a1,a0
@@:
move.b (a5)+,(a0)+
bne @b
lea.l $100(a1),a1
dbra d2,str_dim_init
bra @f
char_dim_init:
move.b (a5)+,(a1)+
dbra d2,char_dim_init
@@:
addq.l #1,a5
move.l a5,d0
bclr #0,d0
movea.l d0,a5
bra main_cont
float_dim_init:
move.l (a5)+,(a1)+
move.l (a5)+,(a1)+
dbra d2,float_dim_init
bra main_cont
int_dim_init:
move.l (a5)+,(a1)+
dbra d2,int_dim_init
bra main_cont
可変長配列定義:
move.w (a5)+,d0 * 配列番号
move.w (a5)+,d3 * 次元 - 1
movea.l 変数area,a1
btst #0,d3
bne @f * 奇数次元の時に
addq.l #2,a1 * 配列の要素がロングワード境界に来るように小細工
@@:
not.w d0
lsl.w #2,d0
move.l a1,Adim(a4,d0.w)
clr.l (a1)+ * offset (無効)
move.w d3,(a1)+ * 次元-1
bsr dim_clr_sub1
move.w d3,d1 * 次元 - 1
@@:
bsr int値get
move.w d0,(a1)+ * 添え字の大きさ
swap d0
tst.w d0
bne 添字大きさ不正
dbra d1,@b
bsr dim_clr_sub2
lea.l (a1,d0.l),a0
cmpa.l mem_last,a0
bcc mem_err
btst #v_initF,d7
beq @f
andi.b #$fc,d0
adda.l d0,a1
bra 1f
@@:
lsr.l #2,d0
moveq #0,d1
bsr a1_clr_d0Lx4
1:
move.l a1,変数area
bra main_cont
添字大きさ不正:
IERROR 36
Switch:
bsr int値get * 値1
adda.l (a5),a5 *** JUMP *** switch table
move.w (a5)+,d2 * case の個数 - 1
bra @f
sw_loop:
addq.l #4,a5
@@:
cmp.l (a5)+,d0
dbeq d2,sw_loop
beq sw_default
addq.l #4,a5
sw_default:
adda.l (a5),a5 *** JUMP ***
bra main_cont
.xdef Switch2
Switch2:
bsr str値get * 値1
moveq #-2,d0 * 文字列長さ
movea.l a0,a1
@@:
addq.w #1,d0
tst.b (a1)+
bne @b
adda.l (a5),a5 *** JUMP *** switch table
move.w (a5)+,d2 * case の個数 - 1
sw_loop2:
move.w (a5)+,d1 * 文字列長さ
cmp.w d0,d1
bne sw2_out
tst.w d1
bmi sw2_ok
movea.l a0,a1
movea.l a5,a2
@@:
cmp.b (a1)+,(a2)+
dbne d0,@b
bne sw2_out2
sw2_ok:
addq.w #3,d1
bclr #0,d1
adda.w d1,a5
bra sw_default
sw2_out2:
move.w d1,d0 * H9/3/5 switch (文字列) の不都合の原因?
sw2_out:
addq.w #3+4,d1 * jump address skip
bclr #0,d1
adda.w d1,a5
dbra d2,sw_loop2
bra sw_default
For:
bsr int値get * 値1
move.l d0,d1
move.w (a5)+,d0 * 変数番号
bmi for_0
movea.l 変数int,a0 * とりあえず兼用
bra @f
for_0:
not.w d0
movea.l Aint(a4),a0
@@:
lsl.w #2,d0
move.l d1,(a0,d0.w)
bsr int値get * 値2
cmp.l d1,d0
blt Break ; changed from bcs (M.Kamada 95.07.09)
addq.l #4,a5
bra main_cont
Goto:
Else:
Break:
Continue:
adda.l (a5),a5 *** JUMP ***
bra main_cont
If:
While:
Until:
bsr int値get * 値1
tst.l d0
bne 条件真
* 偽
adda.l (a5),a5 *** JUMP ***
bra main_cont
条件真:
addq.l #4,a5
bra main_cont
Ifeq:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
beq 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Ifne:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
bne 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Ifgt:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
bgt 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Ifge:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
bge 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Iflt:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
blt 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Ifle:
bsr int値get * 値1
move.l d0,d1
bsr int値get * 値2
cmp.l d0,d1
ble 条件真
adda.l (a5),a5 *** JUMP ***
bra main_cont
Endwhile:
bsr int値get * 値1
tst.l d0
beq 条件偽
* 真
adda.l (a5),a5 *** JUMP ***
bra main_cont
条件偽:
addq.l #4,a5
bra main_cont
Next2:
move.w (a5)+,d0 * 変数番号
bmi 1f
movea.l 変数int,a0 * とりあえず兼用
bra @f
1:
not.w d0
movea.l Aint(a4),a0
@@:
lsl.w #2,d0
addq.l #1,(a0,d0.w)
move.l (a0,d0.w),d1
cmp.l (a5)+,d1 * 特別
bgt for_loop終わった
adda.l (a5),a5 *** JUMP ***
bra main_cont
Next:
move.w (a5)+,d0 * 変数番号
bmi next0
movea.l 変数int,a0 * とりあえず兼用
bra @f
next0:
not.w d0
movea.l Aint(a4),a0
@@:
lsl.w #2,d0
addq.l #1,(a0,d0.w)
move.l (a0,d0.w),d1
bsr int値get * 値2
cmp.l d0,d1
bgt for_loop終わった
adda.l (a5),a5 *** JUMP ***
bra main_cont
for_loop終わった:
addq.l #4,a5
bra main_cont
* こBで使えない命令
Console:
FuncKey:
Width:
Color:
Locate:
Cls:
Input:
Linput:
CursorSW:
IERROR 72 * こBでは使えない命令
console_para_err:
IERROR 53
func_mode_error:
IERROR 73
Screen: * こB(H8/2/14)
bsr int値get
cmpi.l #7,d0
bhi screen_mode_error
move.l d0,-(sp)
.xref _WindowSetScreenMode
bsr _WindowSetScreenMode
addq.l #4,sp
screen_end:
tas sinitFLAG *bset #7
bra main_cont
screen_mode_error:
IERROR 71 * モードが異常
ColorP:
moveq #0,d1 * text color
moveq #4-1,d3
@@:
tst.w (a5)+
bne 1f
move.w d3,-(sp)
bsr int値get
move.l d0,d2
IOCS _TPALET
move.w (sp)+,d3
1:
addq.w #1,d1
bset #6,sinitFLAG * 1回でも変更したらセット
dbra d3,@b
bra main_cont
Beep:
pea.l _beep(pc)
KO_PRINT
addq.l #4,sp
bra main_cont
Lprint:
move.w #4,-(sp) * prn
bset #localF,d7
bra @f
Print:
bclr #localF,d7
@@:
move.w (a5)+,d4
bge print_ctrl
bsr 値get
tst.b d4
beq int_print
bmi float_print
subq.b #1,d4
beq str_print
*char_print:
int_print:
lea.l tmp,a0
move.l a0,-(sp)
move.b #$20,(a0)+
FPACK __LTOS
move.b #$20,(a0)+
clr.b (a0)
KO_PRINT
addq.l #4,sp
bra Print
* move.l d0,-(sp)
* bsr dec_print
* addq.l #4,sp
* bra Print
float_print:
lea.l tmp,a0
move.l a0,-(sp)
move.b #$20,(a0)+
FPACK __DTOS
move.b #$20,(a0)+
clr.b (a0)
KO_PRINT
addq.l #4,sp
bra Print
str_print:
movea.l a0,a1
moveq #-1,d2
moveq #$20,d1
moveq #0,d0
ccloop:
addq.w #1,d2
move.b (a1)+,d0
beq ctrlcodeなし
cmp.b d1,d0
bcc ccloop
add.w d0,d0
move.w _cc(pc,d0.w),d0
beq ccloop
lea.l tmp,a1
move.l a1,-(sp)
subq.w #1,d2
bcs kokop3
@@:
move.b (a0)+,(a1)+
dbra d2,@b
kokop3:
lea.l _cc(pc,d0.w),a2
@@:
move.b (a2)+,(a1)+
bne @b
clr.b (a1)
KO_PRINT
addq.l #4,sp
addq.l #1,a0
bra str_print
_cc:
.dc.w 0 * 00
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0 * 08
.dc.w cc_tab-_cc
.dc.w cc_lf-_cc
.dc.w cc_home-_cc * 0b
.dc.w cc_clr-_cc * 0c
.dc.w cc_cr-_cc
.dc.w 0
.dc.w 0 *cc_Rdown-_cc
.dc.w 0 *cc_Rup-_cc
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0
.dc.w 0 * 18
.dc.w 0
.dc.w cc_Cj-_cc * 1a
.dc.w cc_ESC-_cc
.dc.w cc_r-_cc * 1c
.dc.w cc_l-_cc * 1d
.dc.w cc_u-_cc * 1e
.dc.w cc_d-_cc * 1f
cc_tab: .dc.b 9,0
cc_lf: .dc.b $a,0
cc_home: .dc.b $1e,0
cc_clr: .dc.b $1a,0
cc_cr: .dc.b $d,0
cc_Cj: .dc.b $1b,'[J',0
cc_ESC .dc.b $1b,0
cc_r: .dc.b $1b,'[C',0
cc_l: .dc.b $1b,'[D',0
cc_u: .dc.b $b,0
cc_d: .dc.b $1b,'[B',0
*cc_crlf: .dc.b $d,$a,0
*cc_Rup: .dc.b $1b,'[s',$1b,'[32;H',$a,$1b,'[u',$1b,'[L',0
*cc_Rdown: .dc.b $1b,'[L',0
.even
ctrlcodeなし:
move.l a0,-(sp)
KO_PRINT
addq.l #4,sp
bra Print
print_ctrl:
move.w _pc(pc,d4.w),d4
jmp _pc(pc,d4.w)
_pc:
.dc.w crlf_end-_pc
.dc.w print_end-_pc
.dc.w tab-_pc
.dc.w using_num-_pc
.dc.w using_str-_pc
using_str:
bsr str値get
lea.l tmp,a1
move.l a1,-(sp)
move.w (a5)+,d0
@@:
move.b (a0)+,(a1)+
dbeq d0,@b
bne us_str_調整いらず
subq.l #1,a1
@@:
move.b #$20,(a1)+ * 後ろ余った時の調整
dbra d0,@b
us_str_調整いらず:
clr.b (a1)
bra using_common
using_num:
bsr float値get
lea.l tmp,a0
move.l a0,-(sp)
* move.w (a5)+,d2
* move.w (a5)+,d3
* move.w (a5)+,d4
* ext.l d2
* ext.l d3
* ext.l d4
movem.w (a5)+,d2/d3/d4 *符号拡張するのでこれでOK by Eriko
FPACK __USING
using_common:
KO_PRINT
addq.l #4,sp
bra Print
tab:
pea.l _tab(pc)
KO_PRINT
addq.l #4,sp
bra Print
crlf_end:
pea.l _crlf(pc)
KO_PRINT
addq.l #4,sp
print_end:
tst.w d7
bge main_cont
addq.l #2,sp * prn
bra main_cont
ここまでprint:
subq.w #1,d2
bcs kokop1
lea.l tmp,a1
move.l a1,-(sp)
@@:
move.b (a0)+,(a1)+
dbra d2,@b
clr.b (a1)
KO_PRINT
addq.l #4,sp
kokop1:
addq.l #1,a0
rts
_crlf:
.dc.b 13,10,0
_tab:
.dc.b 9,0
_beep:
.dc.b 7,0
.even
Return:
move.l orgstrbuf(a4),strbuf
move.w (a5)+,d4
move.w d4,-(sp)
bsr 値get
lea.l ret_dat(pc),a1
move.w (sp)+,d4
beq intRET
tst.b d4
bmi floatRET
subq.w #2,d4
beq intRET * ほんとは char だけど
*strRET:
move.l a0,6(a1)
bra _ret
floatRET:
movem.l d0-d1,2(a1)
bra _ret
intRET:
move.l d0,6(a1)
move.l d0,returnNUM
bra _ret
Endfunc:
move.l orgstrbuf(a4),strbuf
lea.l no_ret_dat(pc),a1
moveq #1,d0 * H8/9/2 引き数省略はデフォルトで 1(=デフォルトのイベント処理を行わない)を返す
move.l d0,returnNUM
_ret:
movea.l a1,a0
bra _kob_driven_end
.align 4
no_ret_dat:
.dc.w -1
ret_dat:
.dc.w 0
.dc.l 0,0
Stop:
IERROR 54
Exit: * プログラム実行を終了する
bsr int値get
move.w d0,EXITcode
bra _kob_exec_err * H8/9/1
End: * こっちは「グローバルブロックの終了」
bra _kob_driven_end
** ** ** ** ** ** ** ** **
* d4.b = 型
.xdef function_call
function_call:
move.w (a5)+,d2 * 引き数の個数
move.w d2,d0
lsl.w #4,d0 * いっぱい余るけどいいよね
neg.w d0
lea.l -4*(3+5)-2(sp,d0.w),sp
*レジスタ退避+引き数の個数+引き数(10*個数)
movea.l sp,a1
move.w d2,(a1)+ * 引き数の個数
subq.w #1,d2
bcs fnc_call_loop_end
fnc_call_loop:
move.w (a5)+,d4
bmi 引き数は式
btst #$e,d4
bne 引き数は配列
cmpi.b #$ff,d4
beq 引き数は省略
IERROR 18
引き数は省略:
move.w #$ffff,(a1)+
addq.l #8,a1
bra fnc_call_cont
引き数は配列:
btst #$d,d4
bne 引き数はポインタ
btst #8,d4
bne 引き数はauto配列
movea.l 配列,a0
bra @f
引き数はauto配列:
lea.l Adim(a4),a0
@@:
move.w (a5)+,d0
lsl.w #2,d0
clr.w (a1)+ * これでいい? 調べないと
addq.l #4,a1
move.l (a0,d0.w),(a1)+
bra fnc_call_cont
引き数はポインタ:
moveq #0,d0
move.w (a5)+,d0
tst.b d4
beq intPT
bmi floatPT
cmpi.b #1,d4
bne charPT
strPT:
lsl.l #8,d0
btst #8,d4
bne strPTA
movea.l 変数str,a0
bra @f
strPTA:
movea.l Astr(a4),a0
bra @f
charPT:
btst #8,d4
bne charPTA
movea.l 変数char,a0
bra @f
charPTA:
movea.l Achar(a4),a0
bra @f
floatPT:
lsl.l #3,d0
btst #8,d4
bne floatPTA
movea.l 変数float,a0
bra @f
floatPTA:
movea.l Afloat(a4),a0
bra @f
intPT:
lsl.l #2,d0
btst #8,d4
bne intPTA
movea.l 変数int,a0
bra @f
intPTA
movea.l Aint(a4),a0
@@:
adda.l d0,a0
clr.w (a1)+ * これでいい? 調べないと
addq.l #4,a1
move.l a0,(a1)+
bra fnc_call_cont
引き数は式:
tst.b d4
beq intP
bmi floatP
subq.b #1,d4
bne charP * char
strP:
moveq #1,d4
move.w d2,-(sp)
bsr 値get
move.w (sp)+,d2
move.w #3,(a1)+ * str
addq.l #4,a1
* clr.l (a1)+
move.l a0,(a1)+
bra fnc_call_cont
charP: * char
move.w #2,(a1)+ * char
bra @f
floatP:
move.w d2,-(sp)
bsr 値get
move.w (sp)+,d2
clr.w (a1)+ * float
move.l d0,(a1)+
move.l d1,(a1)+
bra fnc_call_cont
intP:
move.w #1,(a1)+ * int
@@:
move.w d2,-(sp)
bsr int値get
move.w (sp)+,d2
addq.l #4,a1
* clr.l (a1)+
move.l d0,(a1)+
fnc_call_cont:
dbra d2,fnc_call_loop
fnc_call_loop_end:
move.w (a5)+,d0 * 関数番号
bmi 内部関数呼出
lsl.w #4,d0
movea.l 関数buf,a0
movea.l $c(a0,d0.w),a0 * 関数実行アドレス
* KH ' 関数実行アドレス = ',a0
move.w (sp),d2 * 引き数の個数
lsl.w #4,d2 * いっぱい余るけどいいよね
movem.l d5-d7/a2-a6,2(sp,d2.w)
move.l Asysvar(a4),func参照sysvar
.xref _bwp
lea.l _bwp,a3
lea.l _call(pc),a4
jsr (a0) * 関数呼び出し
move.w (sp),d2 * 引き数の個数
lsl.w #4,d2 * いっぱい余るけどいいよね
lea.l 2(sp,d2.w),sp
movem.l (sp)+,d5-d7/a2-a6
move.l d0,errorno
beq 無事実行
btst #errorF,d7
beq 外部func_err
lea.l dummy_fac(pc),a0 * 返り値を用意していない関数用?
無事実行:
rts
.xref _WindowDraw
_call:
.dc.l _WindowDraw
func参照sysvar::
.dc.l 0
外部func_err:
tst.b (a1)
beq @f
move.l a1,-(sp)
KO_PRINT
addq.l #4,sp
1:
tst.b (a1)+
bne 1b
cmpi.b #$0a,-2(a1)
beq @f
pea.l _crlf(pc)
KO_PRINT
addq.l #4,sp
@@:
IERROR 20
dummy_fac:
.dc.w 0
.dc.l 0,-1 * error の時の返り値
内部関数呼出:
not.w d0
lsl.w #4,d0
movea.l 内部関数buf,a0
movea.l 変数area,a2 * 保存
move.w (sp),d2 * 引き数の個数
lsl.w #4,d2 * いっぱい余るけどいいよね
movem.l d5-d7/a2-a6,2(sp,d2.w)
move.l $c(a0,d0.w),-(sp) * 関数実行アドレス
beq 内部関数のアドレスなし
clr.l -(sp) * auto システム変数
bset #modeF,d7 * 内部関数フラグセット
bsr _kob_exec * 関数呼び出し
move.w 4+4(sp),d2 * 引き数の個数
lsl.w #4,d2 * いっぱい余るけどいいよね
lea.l 4+4+2(sp,d2.w),sp
movem.l (sp)+,d5-d7/a2-a6
move.l a2,変数area
rts
内部関数のアドレスなし:
IERROR 2
** ** ** ** ** ** ** **
.offset 4
Fint: .ds.l 1
Fstr: .ds.l 1
Fchar: .ds.l 1
Ffloat: .ds.l 1
Fdim: .ds.l 1
F引数: .ds.l 1
.text
Variable_clr_sub:
move.l (a0)+,d0 * 変数領域サイズ
lea.l (a1,d0.l),a2
cmpa.l mem_last,a2
bcc mem_err
btst #v_initF,d7
beq 1f
movea.l Fint(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * int
addq.w #1,d0
lsl.w #2,d0
adda.w d0,a1
movea.l Fstr(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * str
addq.w #1,d0
lsl.w #8,d0 * 128 個までしかできないけど大丈夫?
adda.w d0,a1
movea.l Fchar(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * char
addq.w #1+3,d0
andi.w #$fffc,d0
adda.w d0,a1
movea.l Ffloat(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * float
addq.w #1,d0
lsl.w #2,d0
adda.w d0,a1
bra @f
1:
moveq #0,d1
movea.l Fint(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * int
addq.w #1,d0
bsr a1_clr_d0x4
movea.l Fstr(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * str
addq.w #1,d0
lsl.w #8-2,d0
bsr a1_clr_d0x4
movea.l Fchar(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * char
addq.w #1+3,d0
lsr.w #2,d0
bsr a1_clr_d0x4
movea.l Ffloat(sp),a2
move.l a1,(a2)
move.w (a0)+,d0 * float
addq.w #1,d0
add.w d0,d0
bsr a1_clr_d0x4
@@:
配列初期:
movea.l Fdim(sp),a2
move.l a2,d0
move.w (a0)+,d4 * 配列の個数 - 1
bmi 配列初期end
配列初期loop:
moveq #0,d3
move.b (a0)+,d3 * 次元 - 1
move.b (a0)+,d1 * 型
btst #0,d3
bne @f * 奇数次元の時に
addq.l #2,a1 * 配列の要素がロングワード境界に来るように小細工
@@:
move.l a1,(a2)+ * 配列ポインタ
clr.l (a1)+ * offset (無効)
move.w d3,(a1)+ * 次元
bsr dim_clr_sub1
move.w d3,d1 * 次元 - 1
@@:
move.w (a0)+,(a1)+ * 添え字の大きさ
dbra d1,@b
bsr dim_clr_sub2
btst #v_initF,d7
beq 1f
andi.b #$fc,d0
adda.l d0,a1
bra 配列初期cont
1:
lsr.l #2,d0
moveq #0,d1
bsr a1_clr_d0Lx4
配列初期cont:
dbra d4,配列初期loop
配列初期end:
move.l a1,変数area
** ** ** **
* 引き数のセット
movea.l 4+引数INIT,a0
adda.w (a5)+,a0 * 引き数リストの先頭アドレス
move.w (a0)+,d3 * 引き数個数 - 1
bmi 引き数setend
movea.l F引数(sp),a1
addq.l #2,a1 * stack に積んである引き数の先頭(引き数の個数飛ばす)
引き数setloop:
move.w (a0)+,d0 * 型
bmi @f
move.w (a0)+,d2 * 配列番号
movea.l Fdim(sp),a2
lsl.w #2,d2
move.l 6(a1),(a2,d2.w) * 配列ポインタ
bra 引き数setcont
@@:
move.w (a0)+,d2 * 番号
tst.b d0
beq int引数
bmi float引数
subq.b #1,d0
beq str引数
* char
movea.l Fchar(sp),a2
movea.l (a2),a2
move.b 6+3(a1),(a2,d2.w)
bra 引き数setcont
str引数:
movea.l Fstr(sp),a2
lsl.w #8,d2
movea.l (a2),a2
lea.l (a2,d2.w),a2
move.l a0,-(sp)
movea.l 6(a1),a0
@@:
move.b (a0)+,(a2)+
bne @b
move.l (sp)+,a0
bra 引き数setcont
float引数:
movea.l Ffloat(sp),a2
lsl.w #3,d2
movea.l (a2),a2
move.l 2(a1),(a2,d2.w)
move.l 6(a1),4(a2,d2.w)
bra 引き数setcont
int引数:
movea.l Fint(sp),a2
lsl.w #2,d2
movea.l (a2),a2
move.l 6(a1),(a2,d2.w)
引き数setcont:
lea.l 10(a1),a1
dbra d3,引き数setloop
引き数setend:
rts
dim_clr_sub1:
moveq #4,d0 * 各項のデータサイズを見る
moveq #2,d2 * size (shift)
tst.b d1 * 型
beq 1f
bmi 2f * float
subq.b #1,d1
beq 3f * str
moveq #1,d0 * char
moveq #0,d2
bra 1f
3:
move.w #$100,d0 * str
moveq #8,d2
bra 1f
2:
moveq #8,d0 * float
moveq #3,d2
1:
move.w d0,(a1)+ * 各項のデータサイズ(1 or 4 or 8 or 256)
rts
dim_clr_sub2:
move.w d3,d1 * 次元 - 1
lsl.w #2,d1
lea.l (a1,d1.w),a3
move.l a3,-(sp)
moveq #1,d0
bra 1f
@@:
move.l d0,-(a3) * 配列計算用のオフセット
1:
moveq #0,d1
move.w -(a1),d1
addq.l #1,d1
FPACK __UMUL
dbra d3,@b
movea.l (sp)+,a1
lsl.l d2,d0
addq.l #3,d0 * 忘れてた
rts
a1_clr_d0Lx4:
subq.l #1,d0
bmi a1_clr_d0x4_end
@@:
move.l d1,(a1)+
dbra d0,@b
clr.w d0
subq.l #1,d0
bcc @b
rts
a1_clr_d0x4:
subq.w #1,d0
bmi a1_clr_d0x4_end
@@:
move.l d1,(a1)+
dbra d0,@b
a1_clr_d0x4_end:
rts
mem_err:
IERROR 1
.end